using System;
using System.Collections.Generic;

namespace LiJ.Framework.Msg.Mos
{
	/// <summary>
	/// 回复图文消息
	/// </summary>
	public class WxNewsReplyMsg : WxBaseReplyMsg
	{
		/// <summary>
		/// 图文列表
		/// </summary>
		public List<WxArticleItem> Items
		{
			get;
			set;
		}

		/// <inheritdoc />
		public WxNewsReplyMsg()
		{
			base.MsgType = "news";
		}

		/// <inheritdoc />
		protected override void SetValueToXml()
		{
			if (this.Items != null && this.Items.Count != 0)
			{
				int num = 0;
				Dictionary<string, object> dictionary = new Dictionary<string, object>(this.Items.Count);
				foreach (WxArticleItem item in this.Items)
				{
					Dictionary<string, object> value = new Dictionary<string, object>
					{
						{
							"Title",
							(object)item.Title
						},
						{
							"Description",
							(object)item.Description
						},
						{
							"PicUrl",
							(object)item.PicUrl
						},
						{
							"Url",
							(object)item.Url
						}
					};
					string key = "item_" + num++;
					dictionary.Add(key, value);
				}
				Tuple<string, IDictionary<string, object>> value2 = new Tuple<string, IDictionary<string, object>>("item", dictionary);
				base["ArticleCount"] = this.Items.Count;
				base["Articles"] = value2;
				return;
			}
			throw new ArgumentNullException("图文内容不能为空！");
		}
	}
}
